﻿///////////////////////////////////////////////////////////////////////////////
// 文件名： EventDelegate.cc
// 作者：   671643387@qq.com
// 日期：   2015年11月2日 下午7:17:57
// 简介：   
///////////////////////////////////////////////////////////////////////////////

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include <graphics/Root.hpp>
#include <graphics/graphics/scenenode/Camera.hpp>
#include <graphics/graphics/scenenode/GraphicsNode.hpp>
#include <graphics/graphics/component/Mesh.hpp>
#include <graphics/graphics/Scene.hpp>

#include "resource.h"

#include "EventDelegate.hpp"

namespace empty
{
    EventDelegate::EventDelegate()
    {

    }

    EventDelegate::~EventDelegate()
    {

    }

    void EventDelegate::OnPreCreateRenderWindow(::graphics::graphics::render::RenderWindow::stProperties& properties)
    {
        properties.width = 1280;
        properties.height = 760;
        properties.icon = MAKEINTRESOURCEW(IDI_ICONAPP);
        properties.iconSmall = MAKEINTRESOURCEW(IDI_ICONAPP);
        properties.title = L"Empty";
        properties.centerScreen = true;
    }

    void EventDelegate::OnRenderWindowCreated(::graphics::graphics::render::RenderWindow* window)
    {

    }

    void EventDelegate::OnRenderWindowShouldShow(::graphics::graphics::render::RenderWindow* window)
    {

    }

    void EventDelegate::OnRootInitialized(::graphics::Root* root)
    {
        ::graphics::graphics::ScenePtr scene(new ::graphics::graphics::Scene());
        if (!scene)
            return;

        ::graphics::graphics::scenenode::CameraPtr camera(new ::graphics::graphics::scenenode::Camera());
        if (!camera)
            return;

        scene->AddCamera(camera);

        {
            ::graphics::graphics::scenenode::GraphicsNodePtr node(new ::graphics::graphics::scenenode::GraphicsNode());
            {
                ::graphics::graphics::component::MeshPtr mesh(new ::graphics::graphics::component::Mesh());
                node->AddComponent(mesh);
            }
            scene->AddGraphicsNode(node);
        }

        root->GetRender()->SetScene(scene);
    }
}